/********************************************************************
	File		: SingletonUpdater.h
	Created		: 2011-4-5	1:07
	Author		: Wjl

	Desc		: This file is part of omiga 2d engine.
*********************************************************************/

#ifndef SingletonUpdater_H__
#define SingletonUpdater_H__

#include <string>
//#include "Debug.h"

namespace Core
{
	class SingletonUpdater
	{
	public:

		virtual void				Update(float _fDelta) = 0;
		const std::string&			GetName() { return m_strName; }

	protected:

		SingletonUpdater(const std::string& _name);

		virtual ~SingletonUpdater();

	private:

		SingletonUpdater(const SingletonUpdater& _other);

		SingletonUpdater& operator = (const SingletonUpdater& _other);

	private:

		std::string					m_strName;
	};

#define DECLARE_SINGLETON(className)	\
	public:\
		static className* Instance();\
		static void Create();\
		static void Release();\
	private:\
		static className* self;

#define IMPLEMENT_SINGLETON(className)	 \
	className* className::self;\
	className* className::Instance()\
	{\
		Debug::Assert(self != 0, "Error : Singleton has not been created !");\
		return self;\
	}\
	void className::Create()\
	{\
		if (0 == self)\
		{\
			self = new className();\
		}\
	}\
	void className::Release()\
	{\
		if (self != 0)\
		{\
			delete self;\
			self = 0;\
		}\
	}\

}
#endif // SingletonUpdater_H__